# ame-server Makefile (amever 0.1)
# kompadre@yandex.ru
CC 	= gcc
OO	= $(CC) -c
DEBUG   = 1
_CC = [Compiling and linking]
_OO = [Compiling object]
CFLAGS = -g2 -pipe
#If efence you want to compile with efence
#CLIBS+= -lefence -lpthread -Bstatic
CLIBS += -lmysqlclient 
CLIBS += -L"/usr/lib/mysql" -lmysqlclient 
CLIBS += -L"/build/lua/lib" -llua -llualib
CINCS  = -I"/build/lua/include" 
CINCS += -I"/usr/local/mysql/include"
CINCS += -I"/usr/include/mysql"
CINCS += -I"src/lua/include"
CDEFS = -DMAINLOOP_SLEEP=100 -D_AME_DEBUG=$(DEBUG) -DCHAIN_SETCLEAR_FAST=1
OBJS  = amever.o buffer.o chain.o client.o map.o 
OBJS += network.o packets.o utils.o lua_w.o path.o
OBJS += game.o mob.o char.o
CLIENT_OBJS = console_client.o

EXESUF =.exe
EXE   = bin/ame-server$(EXESUF) bin/client$(EXESUF)

.PHONY: all clean

all : $(EXE)
#	strip -s $(EXE) 

libs : 
	@echo "Compiling libraries" 
	@cd src/libs; $(MAKE) all

bin/ame-server$(EXESUF): $(OBJS)
	@echo -e "$(_CC) $@"
	@$(CC) $(CFLAGS) $(OBJS) -o $@ $(CLIBS)

bin/client$(EXESUF): $(CLIENT_OBJS)
	@echo -e "$(_CC) $@"
	@$(CC) $(CFLAGS) $(CLIENT_OBJS) -o $@ $(CLIBS)

%.o: src/%.c
	@echo -e "$(_OO) $@"
	@$(OO) $(CDEFS) $(CINCS) $(CFLAGS) $< -o $@

clean:
	@echo "Cleaning up"
	@$(RM) $(EXE) bin/*.exe *.o ./*~ ./src/*~ *.log core

install: $(EXE)
	cp bin/ame-server /usr/bin



# fl.katefl :
#	perl make_filelist.pl $(OBJS) flv-server.h
